package org.example.advice;

import lombok.extern.slf4j.Slf4j;
import org.example.utils.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 宋孟林
 * @description
 */
@RestControllerAdvice
@Slf4j
public class GlobalAdvice {
    /**
     * 处理自定义异常
     * @param e 自定义异常
     * @return 结果
     */
    @ExceptionHandler(CustomException.class)
    public Result<Object> CustomExceptionHandler(CustomException e){
        log.error("出现自定义异常");
        return Result.build(null, 500, e.getMessage());
    }
}
